import React, {createContext} from "react";

export const  ThemeContext = createContext();//通过createContext方法可以创建多个context

//状态管理的文件
class ThemeProvider extends React.Component{
    state = {
        color:"green",
        value:""
    }
    changeColor = () => {
        this.setState({
            color:"blue"
        })
    }
    handleContent = (e) => {
        this.setState({
            value:e.target.value
        })
    }
    render() {
        return <ThemeContext.Provider value={{
                color:this.state.color,
                changeColor:this.changeColor,
                handleContent:this.handleContent,
                value:this.state.value,
            }}>
            {this.props.children}
        </ThemeContext.Provider>
    }
}

export default ThemeProvider;